import {createRouter, createWebHashHistory} from 'vue-router'

// 路由配置
const routes = [
    {
        path: '/',
        children: [
            {
                path: '',
                name: 'MainLayout',
                component: () => import('@/views/layout/MainLayout.vue'),
                children: [
                    {
                        path: '',
                        name: 'MainContent',
                        component: () => import('@/views/layout/MainContent.vue'),
                    },
                    {
                        path: '/post/detail/:id',
                        name: 'PostDetail',
                        component: () => import('@/views/system/post/PostDetail.vue'),
                    },
                    {
                        path: '/search/:keyword',
                        name: 'SearchCenter',
                        component: () => import('@/views/system/search/SearchCenter.vue'),
                    },
                    {
                        path: '/userCenter',
                        name: 'UserCenterLayout',
                        component: () => import('@/views/system/user/userCenter/UserCenterLayout.vue'),
                    }
                ]
            },
        ],
    },
    {
        path: '/postEditor',
        name: 'PostEditor',
        component: () => import('@/views/system/post/component/PostEditor.vue'),
        children: [],
    },
    {
        path: '/aiChat',
        name: 'AIChat',
        component: () => import('@/views/system/ai/chat/AIChat.vue'),
        meta: {
            title: 'AI智能助手'
        }
    }
]

// 创建路由实例
const router = createRouter({
    history: createWebHashHistory(), routes
})
router.beforeEach((to, from, next) => {
    next();
});

export default router